<%@page import="com.common.util.SN_GUID"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//表格动态Id
	request.setAttribute("plugin_id", (int) (Math.random() * 100000));
	request.setAttribute("save_func", request.getParameter("save_func"));
	request.setAttribute("submit_func",
			request.getParameter("submit_func"));
%>
<script type="text/javascript">
function save_${plugin_id}() {
	var url = '${basePath}page/workflow/api/API/queryTaskIdByGuid';
	var data = {"act_form_guid":$("#act_form_guid").val()};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		// 		alert(response + ":" + status + ":" + statusText);
				var canSubmit=false;
				if(response.status){
					var data=response.content;
					if(data[data.length-1]["name"]=="提交"){
							canSubmit=true;
					}
				}else{
// 					alert(response.content);
					canSubmit=true;
				}
				if(canSubmit){
					${save_func eq null?'save':save_func }();
				}else{
					alert("任务正在审核中");
				}
			}
	});
	
}
function submit_${plugin_id}() {
	var url = '${basePath}page/workflow/api/API/queryTaskIdByGuid';
	var data = {"act_form_guid":$("#act_form_guid").val()};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		// 		alert(response + ":" + status + ":" + statusText);
		var canSubmit=false;
				if(response.status){
					var data=response.content;
					if(data[data.length-1]["name"]=="提交"){
						canSubmit=true;
				}
				}else{
// 						alert(response.content);
					canSubmit=true;
				}
				if(canSubmit){
					${submit_func eq null?'submit':submit_func }();
				}else{
					alert("任务正在审核中");
				}
				
			}
	});
	
}
function trace_${plugin_id}(){
	var url = '${basePath}page/workflow/api/API/queryTaskIdByGuid';
	var data = {"act_form_guid":$("#act_form_guid").val()};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		// 		alert(response + ":" + status + ":" + statusText);
				if(response.status){
					var data=response.content;
					for(var i=0;i<data.length;i++){
						var m=data[i];
						if(""!=m["processInstanceId"]){
							open("${basePath}page/workflow/trace/TraceManage/toView?processInstanceId="+m["processInstanceId"]);
						}
						return ;
					}
				}
			}
	});
}
function closeWindow_${plugin_id}() {
	parent.w1.close();
}
</script>
<div>${act_form_guid eq null ?'请在XxxxxxController下增加：String guid=getParam_act_form_guid(request);':''}</div>
<div>${act_form_taskId eq null ?'请在XxxxxxController下增加：String taskId=getParam_act_form_taskId(request);':''}</div>
<div>${save_func eq null ?'请在jsp:include下增加：&lt;jsp:param name="save_func" value="save"/&gt;':''}</div>
<div>${submit_func eq null ?'请在jsp:include下增加：&lt;jsp:param name="submit_func" value="submit"/&gt;':''}</div>
<button onclick="save_${plugin_id}()" class="btn btn-primary" type="button">
	<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
	&nbsp;
	<span>保存</span>
</button>
<button onclick="submit_${plugin_id}()" class="btn btn-primary" type="button">
	<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
	&nbsp;
	<span>提交</span>
</button>
<button onclick="trace_${plugin_id}()" class="btn btn-primary" type="button">
	<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
	&nbsp;
	<span>查看流程图</span>
</button>
<button onclick="closeWindow_${plugin_id}()" class="btn btn-primary" type="button">
	<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
	&nbsp;
	<span>关闭</span>
</button>
<input type="hidden" id="act_form_guid" name="act_form_guid" value="${act_form_guid}" style="">
<input type="hidden" id="act_form_taskId" name="act_form_taskId" value="${act_form_taskId}" style="">